
pkgbase=glib2
pkgname=('glib2' 'glib2-docs')
pkgver=2.56.1
_pkgver=2.56
pkgrel=1
pkgdesc="Common C routines used by GTK+ and other libs"
url="https://www.gtk.org/overview.php"
arch=('x86_64')
makedepends=('pkg-config' 'python3' 'libxslt' 'docbook-xml' 'pcre' 'libffi' 'elfutils')
source=("https://ftp.gnome.org/pub/GNOME/sources/glib/${_pkgver}/glib-${pkgver}.tar.xz"
        'gio-querymodules.hook'
        'glib-compile-schemes.hook'
        'revert_wakeups.patch')
sha256sums=('40ef3f44f2c651c7a31aedee44259809b6f03d3d20be44545cd7d177221c0b8d'
            '5ba204a2686304b1454d401a39a9d27d09dd25e4529664e3fd565be3d439f8b6'
            'e1123a5d85d2445faac33f6dae1085fdd620d83279a4e130a83fe38db52b62b3'
            '05635ffbeb5875fc5cb4adb4c8c85450693c36fc15e4c85f2f04fdbaf7e9d1e8')

prepare() {
  cd glib-${pkgver}
  
  #patch -p1 -i ../revert_wakeups.patch
}
  
build() {
  cd glib-${pkgver}
  
  PYTHON=/usr/bin/python3 ./configure --prefix=/usr --libdir=/usr/lib \
      --sysconfdir=/etc \
      --with-pcre=system \
      --disable-fam
  make
}

package_glib2() {
  depends=('pcre' 'libffi')
  options=('!docs' '!libtool' '!emptydirs')
  license=('LGPL')

  cd glib-${pkgver}
  make DESTDIR=${pkgdir} install
  
  install -dm755 ${pkgdir}/usr/share/libalpm/hooks/
  install -m644 ../glib-compile-schemes.hook ${pkgdir}/usr/share/libalpm/hooks/
  install -m644 ../gio-querymodules.hook ${pkgdir}/usr/share/libalpm/hooks/
}

package_glib2-docs() {
  pkgdesc="Documentation for glib2"
  license=('custom')
  options=('docs' '!emptydirs')
  
  cd glib-${pkgver}/docs
  make DESTDIR=${pkgdir} install
  install -m755 -d ${pkgdir}/usr/share/licenses/glib2-docs
  install -m644 reference/COPYING ${pkgdir}/usr/share/licenses/glib2-docs/

  rm -rf ${pkgdir}/usr/share/man
}
